<script lang="ts">
import { defineComponent } from "vue";

export default defineComponent({
  props: {
    info: { type: Object, required: true },
  },
});
</script>

<template>
  <view class="follow-item">
    <image
      class="follow-item-avatar"
      :src="info.pic_url || info.head_img"
      mode="aspectFill"
    />
    <view class="follow-item-content">
      <view style="display: flex; align-items: center">
        <view class="follow-item-name">{{ info.name || info.nick_name }}</view>
        <view class="follow-item-rank" v-if="info.guider_rank">
          {{ info.guider_rank }}
        </view>
      </view>
      <view style="display: flex; align-items: center" v-if="info.score">
        <view class="follow-item-score">
          {{ info.score }}<text class="follow-item-score2">分</text>
        </view>
        <view class="follow-item-num">{{ info.service_num }}</view>
      </view>
      <view class="follow-item-desc">{{ info.intro }}</view>
    </view>

    <slot />
  </view>
</template>

<style lang="scss">
.follow-item {
  display: flex;
  align-items: center;
  padding: 20rpx;
  border-radius: 20rpx;
  background-color: #ffffff;

  .follow-item-avatar {
    flex-shrink: 0;
    width: 116rpx;
    height: 116rpx;
    border-radius: 50%;
    border: 2rpx solid #f1f1f1;
  }

  .follow-item-content {
    flex-grow: 1;
    min-width: 0;
    margin-left: 20rpx;
  }

  .follow-item-name {
    min-width: 0;
    font-size: 30rpx;
    color: #333333;
    line-height: 40rpx;
    font-weight: bold;
    white-space: nowrap;
    text-overflow: ellipsis;
    overflow: hidden;
  }

  .follow-item-rank {
    flex-shrink: 0;
    margin-left: 10rpx;
    padding: 0 10rpx;
    font-size: 20rpx;
    color: #ff5c1d;
    line-height: 32rpx;
    border-radius: 8rpx;
    background-color: rgba(255, 92, 29, 0.05);
  }

  .follow-item-score {
    flex-shrink: 0;
    font-size: 28rpx;
    color: #0bc6b2;
    line-height: 36rpx;
    font-weight: bold;
  }

  .follow-item-score2 {
    font-size: 24rpx;
    line-height: 24rpx;
    font-weight: 400;
  }

  .follow-item-num {
    min-width: 0;
    margin-left: 4rpx;
    font-size: 20rpx;
    color: #999999;
    line-height: 28rpx;
    white-space: nowrap;
    text-overflow: ellipsis;
    overflow: hidden;
  }

  .follow-item-desc {
    margin-top: 10rpx;
    font-size: 24rpx;
    color: #666666;
    line-height: 34rpx;
    white-space: nowrap;
    text-overflow: ellipsis;
    overflow: hidden;
  }
}
</style>